package com.o2o.repository;

import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Repository;

import com.o2o.base.BaseRepository;
import com.o2o.model.area.Address;

@Scope("prototype") 
@Repository
public class AreaRepository extends BaseRepository{
	
	public Address getAddressByAreaCode(int areaCode){
		String sql = "SELECT CONCAT(province.province,city.city,area.area) AS full_address_detail,province.province,province.province_code,city.city,city.city_code,area.area,area.area_code FROM v_province province,v_city city,v_area AREA"
				+" WHERE city.father_code=province.province_code AND area.father_code=city.city_code AND area.area_code=? ";
		return simpleJdbcTemplate.queryForObject(sql, BeanPropertyRowMapper.newInstance(Address.class), new Object[]{areaCode});
		
	}

}
